/**   
 * @Title: ResourceService.java 
 * @Package com.betterjr.modules.workflow.snaker.core 
 * @Description: 流程实例操作类
 * @author licz
 * @date 2017年10月30日 下午3:03:48  
 */
package com.betterjr.modules.risk.loanmanage.service;

import java.sql.Timestamp;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.common.service.BaseService;
import com.betterjr.common.utils.BTAssert;
import com.betterjr.common.utils.BetterDateUtils;
import com.betterjr.mapper.pagehelper.Page;
import com.betterjr.modules.risk.loanmanage.dao.PaymentDataMapper;
import com.betterjr.modules.risk.loanmanage.entity.PaymentData;
import com.betterjr.modules.risk.loanmanage.util.BetterBeanUtils;

@Service
public class PaymentDataService extends BaseService<PaymentDataMapper, PaymentData> {

    public Page<PaymentData> listPaymentData(final PaymentData paymentData, final int pageNum, final int pageSize) {
        return this.selectByPage(paymentData, pageNum, pageSize, true);
    }

    /** 
     * @Title: savePaymentData 
     * @Description: 定时跑的，user信息是system
     * @param paymentData
     * @return
     * @throws 
     * @author licz
     * @date 2018年7月17日 下午7:12:14 
     */
    public PaymentData savePaymentData(final PaymentData paymentData) {
        paymentData.setCreatorId(1L);
        paymentData.setCreator("system");
        paymentData.setCreateDate(Timestamp.valueOf(BetterDateUtils.getDateTime()));
        if (!ObjectUtils.isEmpty(paymentData.getId())) {
            this.updateByPrimaryKeySelective(paymentData);
        } else {
            final Long baseId = SerialGenerator.getLongValue(PaymentData.selectKey);
            paymentData.setId(baseId);
            this.insertSelective(paymentData);
        }
        return paymentData;
    }

    public PaymentData savePaymentData(final Map<String, Object> param) {

        final PaymentData paymentData = new PaymentData();
        BetterBeanUtils.copyProperties2Bean(paymentData, param);
        BTAssert.notNull(paymentData, "参数不允许为空！");
        return savePaymentData(paymentData);
    }

}
